package com.hzit.client;

import com.hzit.entity.User;
import com.hzit.util.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@Slf4j
public class UserClientFactory implements FallbackFactory<UserClient> {
	@Override
	public UserClient create(Throwable t) {
		return new UserClient() {
			@Override
			public R<List<User>> list() {
				log.info("访问用户列表失败，原因是：{}",t.getMessage());
				return R.fail("访问用户列表失败(UserClientFactory)！");
			}

			@Override
			public R getPort() {
				log.info("访问用户端口失败，原因是：{}",t.getMessage());
				return R.fail("访问用户端口失败(UserClientFactory)！");
			}
		};
	}
}
